import {MiddlewareConsumer, Module, NestModule} from '@nestjs/common'
import {AppController} from './app.controller'
import {CatController} from './cat.controller'
import {AppService,CatService} from './all.middleware'
import {BookModule} from './book/book.module';
@Module({
    controllers:[
        AppController,
        CatController
    ],
    imports:[
        BookModule
    ]
})
export class AppModule implements NestModule{
    configure(consumer: MiddlewareConsumer) {
        // consumer 链式操作.apply .forRoutes 这里绑定的apply只针对之后的routes；不可以跳着操作的
        consumer
            .apply(AppService)
            .forRoutes(AppController)
            .apply(CatService)
            .forRoutes(CatController)

        // 如果需要同时绑定给双方
        // consumer.apply(AppService,CatService).forRoutes(AppController,CatController)
    }
}
